library(tidyverse)
 library(lsa)
 library(ggplot2)
 library(plotly)
rm(list = ls())
df.cosine <- readRDS("df.cosine.RDS")

df0_all_news_2 <- readRDS("df0-all-news-2.RDS")
df0_all_news_2 %>% select(link, postdate) -> df0_all_news_2
df0_all_news_2 <- df0_all_news_2[!duplicated(df0_all_news_2$link),]
df.cosine <- left_join(df.cosine, df0_all_news_2)

df.cosine %>% filter(postdate > as.POSIXct("2016-01-01", tz="MSK")) -> df.cosine

g <- df.cosine %>% ggplot(aes(x = item,
                         y = similarity,
                         fill=item,
                         label = site))+
   geom_boxplot()+
   facet_wrap(~site)
ggplotly(g)
g <- df.cosine %>% ggplot(aes(x = item,
                         y = similarity))+
   geom_jitter()+
   facet_wrap(~site)
print(g)

g <- df.cosine %>% ggplot(aes(x = item, y = similarity))+
   geom_boxplot()+coord_flip()+
   facet_grid(~site)
ggplotly(g)
g <- df.cosine %>% ggplot(aes(x = similarity, fill = item))+
   geom_density(position = 'identity', alpha = 0.8, adjust = 1)+
   facet_grid(site ~ .)
ggplotly(g)
g <- df.cosine %>% ggplot(aes(x = similarity, fill = site))+
   geom_density(position = 'identity', alpha = 0.8, adjust = 1)+
   facet_grid(item ~ .)
ggplotly(g)
#
g <- df.cosine %>% ggplot(aes(x = similarity, fill = item))+
   geom_density(position = 'fill', alpha = 0.8, adjust = 1)+
   facet_grid(site ~ .)
ggplotly(g)
g <- df.cosine %>% ggplot(aes(x = similarity, fill = site))+
   geom_density(position = 'fill', alpha = 0.8, adjust = 1)+
   facet_grid(item ~ .)
ggplotly(g)
g <- df.cosine %>%  
      ggplot(aes(x = postdate, y = similarity, label =  link, colour = item)) +
   geom_point(alpha = 0.5)+
   facet_wrap(~site)
print(g)   

g <- df.cosine %>%  
   ggplot(aes(x = postdate, y = similarity, label =  link, colour = item)) +
   geom_point(alpha = 0.5)+
   facet_grid(site ~.)
print(g)